/**
 * Created by kaki on 2017/11/3.
 */
import http from 'src/utils/http'
import { host } from 'src/config'
import { requestMe } from 'src/api/other'

// 预约列表
export const GetMybooking = () => {
  const url = host + `user/schedules-booking`
  const data = {
    include: 'schedules_course',
    canceled: 0
  }
  return http.get(url, data)
}
// 取消预约列表
export const GetMyRebooking = () => {
  const url = host + `user/schedules-booking`
  const data = {
    include: 'schedules_course',
    canceled: 1
  }
  return http.get(url, data)
}
// 取消预约
export const canelBooking = (id) => {
  const url = host + `user/schedules-booking/${id}/cancel`
  return http.del(url)
}
// 获取签到二维码
export const getCode = (id) => {
  const url = host + `user/schedules-booking/${id}/sign-qrcode`
  return http.get(url)
}
// 扫码签到团课
export const courseSign = (code) => {
  const url = host + `user/schedules-booking/sign-in`
  return http.post(url, {code})
}
// 赠卡列表
export const giftCardsList = () => {
  const url = host + `user/gift-cards?include=gift_card,gift_card.cards_type`
  return http.get(url)
}
// 赠卡详情
export const showGiftCard = (id) => {
  const url = host + `user/gift-cards/${id}?include=gift_card,gift_card.cards_type`
  return http.get(url)
}
// 获取分享ticket
export const shareTicket = (id) => {
  const url = host + `user/gift-cards/${id}/share`
  return http.post(url)
}
// 参与支持
export const participate = async (ticket) => {
  const url = `${host}user/gift-cards/share/${ticket}`
  return http.post(url)
}

// 分享详情
export const showShareDetail = (ticket) => {
  const url = host + `user/gift-cards/share/${ticket}?include=records,records.to_user_socialites,gift_card,condition,card_type`
  return http.get(url)
}
